﻿namespace Devonline.Entity;

/// <summary>
/// 具有日期和时间范围的数据对象模型基类
/// 字符串主键的默认实现
/// </summary>
public abstract class EntitySetWithDateTimeRange : EntitySetWithDateTimeRange<string>, IDateTimeRange, IEntitySet, IEntitySetWithCreate { }

/// <summary>
/// 具有日期和时间范围的数据对象模型基类
/// </summary>
public abstract class EntitySetWithDateTimeRange<TKey> : EntitySetWithCreate<TKey>, IDateTimeRange<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey> where TKey : IConvertible
{
    public EntitySetWithDateTimeRange()
    {
        StartOn = DateTime.UtcNow;
    }

    /// <summary>
    /// 起始时间
    /// </summary>
    [Column("start_on"), DisplayName("起始时间"), Excel]
    public virtual DateTime StartOn { get; set; }
    /// <summary>
    /// 结束时间
    /// </summary>
    [Column("end_on"), DisplayName("结束时间"), Excel]
    public virtual DateTime? EndOn { get; set; }
}

/// <summary>
/// 具有日期范围的数据对象模型基类
/// 字符串主键的默认实现
/// </summary>
public abstract class EntitySetWithDateRange : EntitySetWithDateRange<string>, IDateRange, IEntitySet, IEntitySetWithCreate { }

/// <summary>
/// 具有日期范围的数据对象模型泛型基类
/// </summary>
public abstract class EntitySetWithDateRange<TKey> : EntitySetWithCreate<TKey>, IDateRange<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey> where TKey : IConvertible
{
    public EntitySetWithDateRange()
    {
        StartOn = DateOnly.FromDateTime(DateTime.UtcNow);
    }

    /// <summary>
    /// 起始日期
    /// </summary>
    [Column("start_on"), DisplayName("起始日期"), Excel]
    public virtual DateOnly StartOn { get; set; }
    /// <summary>
    /// 结束日期
    /// </summary>
    [Column("end_on"), DisplayName("结束日期"), Excel]
    public virtual DateOnly? EndOn { get; set; }
}

/// <summary>
/// 具有时间范围的数据对象模型基类
/// 字符串主键的默认实现
/// </summary>
public abstract class EntitySetWithTimeRange : EntitySetWithTimeRange<string>, ITimeRange, IEntitySet, IEntitySetWithCreate { }

/// <summary>
/// 具有时间范围的数据对象模型泛型基类
/// </summary>
public abstract class EntitySetWithTimeRange<TKey> : EntitySetWithCreate<TKey>, ITimeRange<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey> where TKey : IConvertible
{
    public EntitySetWithTimeRange()
    {
        StartOn = TimeOnly.MinValue;
    }

    /// <summary>
    /// 起始时间
    /// </summary>
    [Column("start_on"), DisplayName("起始时间"), Excel]
    public virtual TimeOnly StartOn { get; set; }
    /// <summary>
    /// 结束时间
    /// </summary>
    [Column("end_on"), DisplayName("结束时间"), Excel]
    public virtual TimeOnly? EndOn { get; set; }
}